-module(db).
-export([connect/0, insert_user/2, insert_log/3]).

connect() ->
    mysql:start_link([{host, "localhost"}, {user, "root"}, {password, "password"}, {database, "chatgpt_db"}]).

insert_user(Username, Password) ->
    mysql:query(mysql:prepare(<<"INSERT INTO users (username, password) VALUES (?, ?)">>, [Username, Password])).

insert_log(FromUser, ToUser, Message) ->
    mysql:query(mysql:prepare(<<"INSERT INTO message_logs (from_user, to_user, message) VALUES (?, ?, ?)">>, [FromUser, ToUser, Message])).
